#region (c) 2014 THN Solutions LLC. - All rights reserved
/*
Simplified BSD License (BSD)
Copyright (c) 2014, THN Solutions LLC. ( www.ThnSolutions.com )
Author: Nguyễn, M. Hải                 ( www.Minh-Hai.com     )
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this 
      list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
      this list of conditions and the following disclaimer in the documentation 
      and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY OF SUCH DAMAGE.
*/
#endregion

#region Record of Change
//             							CHANGE HISTORY
// -------------------------------------------------------------------------------------
// |   DATE    | DEVELOPER  | DESCRIPTION                                              |
// -------------------------------------------------------------------------------------
// | 12-Nov-09 | HaiNM      | First creation.                                          |
// -------------------------------------------------------------------------------------
//
#endregion

#region Record of Audit
//             							REVIEW HISTORY
// -------------------------------------------------------------------------------------
// |   DATE    | REVIEWER   | NOTES                                                    |
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
//
#endregion

#region Using directives
using System;

using Thn;
#endregion

namespace Thn.Interface.Vcl
{
    /// <summary>
    /// A page manager is responsible for handling pages.
    /// </summary>
#if DEBUG
    public
#else
    public
#endif
    interface IPageManager
    {
        #region Register
        /// <summary>
        /// Register a page to be managed by this manager.
        /// <para>Note that the page will be root-page (no parent)</para>
        /// </summary>
        /// <param name="pageID">Identifier of page</param>
        /// <param name="name">Description of page</param>
        /// <param name="pageType">Type of page</param>
        void Register(string pageID, string name, Type pageType);

        /// <summary>
        /// Register a page to be managed by this manager.
        /// <para>The page's hierachy as well as control type will be obtained from descriptor</para>
        /// </summary>
        /// <param name="descriptor">Description of page</param>
        void Register(IPageDescriptor descriptor);
        #endregion

        #region Show
        /// <summary>
        /// Display a page
        /// </summary>
        /// <param name="pageID">Identifier of page</param>
        void Show(string pageID);

        /// <summary>
        /// Display a page with specified parameters
        /// </summary>
        /// <param name="pageID">Identifier of page</param>
        /// <param name="parameters">Optional parameters for the page</param>
        void Show(string pageID, params object[] parameters);

        /// <summary>
        /// Display a page
        /// </summary>
        /// <param name="descriptor">Page description</param>
        void Show(IPageDescriptor descriptor);

        /// <summary>
        /// Display a page with specified parameters
        /// </summary>
        /// <param name="descriptor">Page description</param>
        /// <param name="parameters">Optional parameters for the page</param>
        void Show(IPageDescriptor descriptor, params object[] parameters);

        /// <summary>
        /// Display a page
        /// </summary>
        /// <param name="context">The request context.</param>
        void Show(PageShowContext context);
        #endregion

        #region Current Page
        /// <summary>
        /// Gets the page being shown
        /// </summary>
        IPageDescriptor CurrentPage
        { get; }
        #endregion

        #region Navigation
        /// <summary>
        /// Clear navigation history
        /// </summary>
        void ClearHistory();

        /// <summary>
        /// Move to next page
        /// </summary>
        void Forward();

        /// <summary>
        /// Is there any page to move forward
        /// </summary>
        bool CanForward
        { get; }

        /// <summary>
        /// Move to previous page
        /// </summary>
        void Back();

        /// <summary>
        /// Is there any page to move back
        /// </summary>
        bool CanBack
        { get; }

        #region Back History
        /// <summary>
        /// Gets the page history for back navigation.
        /// </summary>
        IPageHistory BackHistory
        { get; }
        #endregion

        #region Forward History
        /// <summary>
        /// Gets the page history for forward navigation.
        /// </summary>
        IPageHistory ForwardHistory
        { get; }
        #endregion

        #endregion

        #region Get Descriptor
        /// <summary>
        /// Find the page descriptor
        /// </summary>
        /// <param name="pageID">Identifier of page</param>
        IPageDescriptor GetDescriptor(string pageID);
        #endregion

        #region Events
        /// <summary>
        /// Fired when a page has been shown
        /// </summary>
        event PageShownHandler PageShown;

        /// <summary>
        /// Fired when a page has been hidden
        /// </summary>
        event PageEventHandler PageHidden;
        #endregion
    }

    /// <summary>
    /// Page management related events
    /// </summary>
    /// <param name="manager">The manager that raises this event</param>
    /// <param name="page">The page description.</param>
    public delegate void PageEventHandler(IPageManager manager, IPageDescriptor page);

    /// <summary>
    /// Page shown event handler.
    /// </summary>
    /// <param name="manager">The manager that showed the page.</param>
    /// <param name="context">Settings used for showing the page.</param>
    public delegate void PageShownHandler(IPageManager manager, PageShowContext context);
}
